package com.eseo.munchkinarbiter;

public class PlayerStats {
	private GameData gameData;
	private String name;
	private boolean isWarrior;
	private int level;
	private int gear;

	public PlayerStats(GameData gameData, String name) {
		this.gameData = gameData;
		this.name = name;
		this.isWarrior = false;
		this.level = 1;
		this.gear = 0;
	}
	
	public PlayerStats(GameData gameData, String name, boolean isWarrior, int level, int gear) {
		this.gameData = gameData;
		setName(name);
		setWarrior(isWarrior);
		setLevel(level);
		setGear(gear);
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
		gameData.onPlayerNameChanged(this);
	}
	
	public boolean isWarrior() {
		return isWarrior;
	}
	
	public void setWarrior(boolean isWarrior) {
		this.isWarrior = isWarrior;
		gameData.onWarriorStateChanged(this);
	}
	
	public int getLevel() {
		return level;
	}
	
	public void setLevel(int level) {
		if(level < 1)
			level = 1;
		if(level > GameConfig.maxLevel)
			level = GameConfig.maxLevel;
	
		this.level = level;
		gameData.onPlayerLevelChanged(this);
	}
	
	public int incLevel() {
		if(level >= GameConfig.maxLevel)
			return level;
		
		++level;
		gameData.onPlayerLevelChanged(this);

		return level;
	}
	
	public int decLevel() {
		if(level <= 1)
			return level;
		
		--level;
		gameData.onPlayerLevelChanged(this);
		
		return level;
	}
	
	public int getGear() {
		return gear;
	}
	
	public void setGear(int gear) {
		this.gear = gear;
		gameData.onPlayerGearChanged(this);
	}
	
	public int incGear() {
		++gear;
		gameData.onPlayerGearChanged(this);
		
		return gear;
	}
	
	public int decGear() {
		--gear;
		gameData.onPlayerGearChanged(this);
		
		return gear;
	}
	
	public int getStrength() {
		return level + gear;
	}
}
